package com.campus.service.Impl;

import com.campus.domain.Dto.TeacherAddDto;
import com.campus.domain.Vo.TeacherSelectVo;
import com.campus.mapper.TeacherMapper;
import com.campus.mapper.UserMapper;
import com.campus.service.ITeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
public class TeacherServiceImpl implements ITeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    @Transactional
    public Integer addTeacher(TeacherAddDto teacherAddDto) {

        Long loginId = userMapper.addUser(teacherAddDto.getUserRegisterDto());

        return teacherMapper.addTeacher(teacherAddDto,loginId);
    }

    @Override
    public TeacherSelectVo selectById(Long id) {
        return teacherMapper.selectById(id);
    }
}
